
SET(SYSROOT "${ANDROID_NDK_ROOT}/platforms/${ANDROID_PLATFORM}/arch-arm")
SET(TARGET_LIBGCC "${CMAKE_C_COMPILER} -mthumb-interwork -print-libgcc-file-name")
SET(CMAKE_C_FLAGS
"-fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -D__ANDROID__ -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -march=armv5te -mtune=xscale -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -DANDROID -O2 -DNDEBUG -g -MMD -MP -MF -g")


SET(CMAKE_CXX_FLAGS
"-fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -D__ANDROID__ -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -march=armv5te -mtune=xscale -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -DANDROID -O2 -DNDEBUG -g -MMD -MP -MF -fno-exceptions -fno-rtti")

add_definitions(-DGTEST_HAS_STD_WSTRING=0)

SET(CMAKE_SHARED_LINKER_FLAGS "--sysroot=${SYSROOT} -nostdlib -Wl,-shared,-Bsymbolic -Wl,--no-undefined -Xlinker --allow-multiple-definition")
SET(CMAKE_EXE_LINKER_FLAGS "--sysroot=${SYSROOT} -L${SYSROOT}/usr/lib -nostdlib -Bdynamic -Wl,-dynamic-linker,/system/bin/linker -Wl,--gc-sections -Wl,-z,nocopyreloc -lc -lm") #${SYSROOT}/usr/lib/crtbegin_dynamic.o -Wl,--no-undefined -Wl,-rpath-link=${SYSROOT}/usr/lib ${TARGET_LIBGCC} ${SYSROOT}/usr/lib/crtend_android.o

SET(CMAKE_REQUIRED_INCLUDES 
"${SYSROOT}/usr/include"
"${ANDROID_NDK_ROOT}/sources/cxx-stl/stlport/stlport"
)
SET(CMAKE_REQUIRED_FLAGS ${CMAKE_EXE_LINKER_FLAGS})

INCLUDE_DIRECTORIES( ${CMAKE_REQUIRED_INCLUDES} )
LINK_DIRECTORIES(
"${TOOLCHAIN_ROOT}/arm-linux-androideabi/lib"
"${ANDROID_NDK_ROOT}/sources/cxx-stl/stlport/libs/armeabi"
"${SYSROOT}/usr/lib")

SET( ENABLE_UNIT_TESTS 0 )

if( NOT CMAKE_BUILD_TYPE )
	set( CMAKE_BUILD_TYPE "Debug" )
endif( NOT CMAKE_BUILD_TYPE )

string(TOLOWER ${CMAKE_BUILD_TYPE} ANT_MODE)

#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${NANE_BINARY_DIR}/android/libs")

set(SHELL_COMMAND)
if( CMAKE_HOST_SYSTEM_NAME STREQUAL Windows )
	set(SHELL_COMMAND "cmd /c")
endif( CMAKE_HOST_SYSTEM_NAME STREQUAL Windows )

nane_override_implementations( RenderSystem )
nane_add_implementation( RenderSystem ogl )

set( NANE_PLATFORM_LIBS "log;m;c;stlport_static;supc++;gcc;${CMAKE_DL_LIBS}" )
